<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>故障诊断</title>

  <link rel="stylesheet" type="text/css" href="easyui/themes/material/easyui.css">
  <link rel="stylesheet" type="text/css" href="easyui/themes/color.css">
  <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
  <script type="text/javascript" src="easyui/jquery.min.js"></script>
  <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
  <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>

  <script src="web/JS/URLRooter.js"></script>
  <script src="web/JS/common.js"></script>

  <style>
  </style>
  <script>
    // 用户ID
    let id = getUrlParam("id");
    // let path = getPath();
    $(function () {
      GetUserRole();
      // loadData();
    });
    //获取用户权限
    function GetUserRole() {
      // let thisdata = [];
      // thisdata.push(InitRole(id));
      let USERdata = InitRole(id);
      if (USERdata != null) {
        loadData();
      }
      else OpenErrmsg("web/errhtml/404.html");
    }
    function loadData() {
      getlistdata(1, 10)
      $('#dg_DateList').datagrid({
        data: listdata
      });
      $('#dg_pagination').pagination({
        total: total,
        onSelectPage: function (pageNumber, pageSize) {
          getlistdata(pageNumber, pageSize)
          $('#dg_DateList').datagrid({
            data: listdata
          });
        },
        onRefresh: function (pageNumber, pageSize) {
          $('#dg_pagination').pagination('refresh', {	// 改变选项并刷新分页栏信息
            total: total,
            pageNumber: 1
          });
          getlistdata(1, 10)
          $('#dg_DateList').datagrid({
            data: listdata
          });
        }
      });
    }
    var listdata = []
    var total = ''
    let path = getDataPath();
    function getlistdata(pageNumber, pageSize) {
      let url = path + '/ls172/data-analysis/faultDiagnosis'
      var params = {
        "pageNum": pageNumber,
        "pageSize": pageSize,
      }
      $.ajax({
        url: url,
        type: "post",
        async: false,
        dataType: "json",
        headers: {
          Accept: "application/json",
          "Content-Type": "application/json"
        },
        data: JSON.stringify(params),

        success: function (data) {
          listdata = data.data.records
          total = data.data.total
        },
        error: function (data) {
          console.log("code", data);
        }
      })
    }
  </script>
</head>

<body class="easyui-layout">
  <div data-options="region:'north',title:''"
    style="height:60px;padding:25px 10px 5px 20px;font-size: large;font-weight: bold;">
    故障诊断
  </div>
  <div data-options="region:'center',title:''" style="padding:5px;">
    <table id="dg_DateList"
      data-options="singleSelect:true,border:false,rownumbers:true,fitColumns:true,fit:true,nowrap:true,showHeader:true">
      <thead>
        <tr>
          <th data-options="field:'custom0',width:80,align:'center'">位置</th>
          <th data-options="field:'almtime',width:60,align:'center'">时间</th>
          <th data-options="field:'custom1',width:60,align:'center'">故障类型</th>
          <th data-options="field:'almdesc',align:'center'">备注</th>
        </tr>
      </thead>
      <tfoot>
        <div id="dg_pagination"
          style="background:#efefef;border:1px solid #ccc;position: absolute;bottom: 0;z-index: 10;width: 100%;"></div>
      </tfoot>
    </table>
  </div>
</body>

</html>